package cxt.cn.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.io.IOException;
import java.util.List;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cxt.cn.domain.Student;
import cxt.cn.service.StudentService;

@Controller
@RequestMapping("/student")
public class StudentController {
        @Autowired
        private StudentService studentService;
        @RequestMapping("/controller")
        public String findAll(Model model) {
            System.out.println("表现层：查询所有账户...");
            List<Student> all = studentService.findAll();
            model.addAttribute("list",all);
            return "list";
        }
        @RequestMapping("/controller1")
        public void save(Student student, HttpServletRequest request, HttpServletResponse response) throws IOException {
            System.out.println("表现层：查询所有账户...2");
            studentService.save(student);
            response.sendRedirect(request.getContextPath()+"/student/controller");

        }
}
